package com.eco.fanliapp.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.eco.fanliapp.entity.AppUserOrder;
import com.eco.fanliapp.entity.JdUserOrder;
import com.eco.fanliapp.entity.PddUserOrder;
import com.eco.fanliapp.vo.AppUserFansTeamVo;
import com.eco.fanliapp.vo.SyChannelUserVO;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 用户和订单中间 服务层
 * 
 * @author xiaoxx
 * @date 2019-04-24
 */
public interface IAppUserOrderService extends IService<AppUserOrder>
{
	/**
     * 查询用户和订单中间信息
     * 
     * @param tableId 用户和订单中间ID
     * @return 用户和订单中间信息
     */
	AppUserOrder selectAppUserOrderById(Integer tableId);
	
	/**
     * 查询用户和订单中间列表
     * 
     * @param appUserOrder 用户和订单中间信息
     * @return 用户和订单中间集合
     */
	List<AppUserOrder> selectAppUserOrderList(AppUserOrder appUserOrder);
	
	/**
     * 新增用户和订单中间
     * 
     * @param appUserOrder 用户和订单中间信息
     * @return 结果
     */
	int insertAppUserOrder(AppUserOrder appUserOrder);
	
	/**
     * 修改用户和订单中间
     * 
     * @param appUserOrder 用户和订单中间信息
     * @return 结果
     */
	int updateAppUserOrder(AppUserOrder appUserOrder);
		
	/**
     * 删除用户和订单中间信息
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
	int deleteAppUserOrderByIds(String ids);

	AppUserOrder selectAppUserOrderBybalanceCount(Long userId);

	  /**
     * 查询该用户绑定订单数
     * @param userId
     * @return
     */
    int countBingOrderSum(Long userId);
    /**
     * 根据订单号查询订单是否已经入库
     * @param tradeId
     * @return
     */
	AppUserOrder selectAppUserOrderByTradeId(Long tradeId);
	 /**
     * 根据订单号查询订单是否已经入库
     * @param tradeId
     * @return
     */
	List<AppUserOrder> selectAppUserOrderListByTradeId(Long tradeId);

	double findBalanceListByUserId(Long userId, int i);
	
	HashMap<String, Object> findBalanceByUserIdSum(Long userId, int i);
	
	HashMap<String, Object> findFansSuperBalanceSumByUserId(List<Long> userId, int i);

	String findFansLevelBalanceSumByUserId(Long userId, int i);

	List<AppUserOrder> selectLargeAmountYesList(Long starTime,Long endTime);

	List<AppUserOrder> selectAppUserOrderByUserId(Long userId);

	List<AppUserOrder> selectAppUserOrderByUserIdAndTkStatus3(Long userId);


	/**
	 * 查询订单数量（根据userId）
	 *
	 * @param userIds
	 * @return
	 */
	int buyNumByAllId(List<Long> userIds);


	/**
	 * 查询用户购买免单商品订单数量（根据userId）
	 *
	 * @param taobaoUserId
	 * @return
	 */
	int buyFreeNumByAllId(Long taobaoUserId);
	/**
	 * 查询用户订单分佣金额
	 * @param userId
	 * @param tradeId
	 * @return
	 */
	AppUserOrder findUserIdOrderId(Long userId, Long tradeId);



	/**
	 * 取我的收益-入账中订单-包含自己订单，直接粉丝订单，间接粉丝订单，分享赚订单     tkStatus = 12
	 * @param userId
	 * @param invoCode
	 * @return
	 */
	List<AppUserOrder> getMeBookedOrderDetail(Long userId, String invoCode, Integer pageNum, Integer pageSize);

	List<AppUserOrder> selectUserOrder(Long userId);

	/**
	 * 我的团队-->>我的下级
	 * @param userId
	 * @param pageNum
	 * @param pageSize
	 * @return
	 */
    List<AppUserFansTeamVo> findFansTeamList(Long userId, Integer pageNum, Integer pageSize);

	/**
	 *  两个时间戳都传查之间的  传起始查大于它的
	 * @param flag 今日佣金
	 * @param companyId
	 * @param startTime
	 * @param endTime
	 * @return
	 */
	Double statisticsCommission(Integer flag, Integer companyId, long startTime, long endTime);

	/**
	 * 查询昨日复购人数
	 * @return
	 * @param companyId
	 * @param startTime
	 * @param endTime
	 */
	Integer yesterdayOrderRepeat(Integer companyId, Integer flag, long startTime, long endTime);

	/**
	 * 单比0元购成本
	 * @return
	 * @param companyId
	 * @param flag
	 * @param startTime
	 * @param endTime
	 */
	double singleZeroPurchaseCost(Integer companyId, Integer flag, long startTime, long endTime);

	/**
	 * 昨日0元购成本
	 * @return
	 */
	double yesterdayZeroPurchaseCost();

	/**
	 * 首单总数
	 * @return
	 * @param companyId
	 * @param flag
	 * @param startTime
	 * @param endTime
	 */
	int firstShareRatio(Integer companyId, Integer flag, long startTime, long endTime);

	/**
	 * 昨日首单总数
	 * @return
	 */
	int yesterdayFirstShareRatio();

	/**
	 * 昨日新增下单用户
	 * @return
	 * @param companyId
	 */
	Integer yesterdayAddingUsers(Integer companyId,Integer flag);

	/**
	 * 单比首单成本
	 * @return
	 */
	String singleInitialCost(Integer companyId, Integer param);

	/**
	 * 昨日免单补贴金额
	 * @return
	 * @param companyId
	 */
	Integer yesterdaySubsidyFreeAmount(Integer companyId);

	/**
	 * 昨天免单联盟佣金
	 * @return
	 * @param companyId
	 */
	Double freeAllianceCommissionYesterday(Integer companyId, Integer type, Long startDate, Long endDate);

	/**
	 * 根据公司统计总下单用户
	 * @param companyId
	 * @return
	 */
	Integer totalOrderUserRegistration(Integer companyId);

	/**
	 * 昨日总下单用户
	 * @param companyId
	 * @return
	 */
	Integer yesterdayOrderQuantity(Integer companyId);

	/**
	 * 查询总订单数
	 *
	 * @param id
	 * @param companyId
	 * @param startTime
	 * @param endTime
	 * @return
	 */
	Integer selectTotalOrder(Integer companyId, Integer flag, long startTime, long endTime);

	/**
	 * 限时秒杀佣金
	 * @param companyId
	 * @param flag
	 * @return
	 */
	Double timeLimitedCommission(Integer companyId, Integer flag,Integer types);

	/**
	 * 今日爆款佣金
	 * @param companyId
	 * @param flag
	 * @return
	 */
	String todayHotCommission(Integer companyId, Integer flag);

	/**
	 * 查券佣金
	 * @param companyId
	 * @param flag
	 * @return
	 */
	String voucherCommission(Integer companyId, Integer flag);

	/**
	 * 查询用户购买订单数量（费免单）
	 * @param userid
	 * @return
	 */
    Integer getOrderCountNumber(Long userid);
	/**
	 * 判断是否可以提现
	 */
	Boolean withdrawPermissionCount(Long userId);

	Double singleFixedReturnYesterday(Integer companyId, Integer flag);

	SyChannelUserVO selectOrderMessage(Long channelId, String searchDate);

	Integer selectOrderUser(Long companyId, Integer flag,Integer freeFlag);

	Integer recommendedOrderNum(Integer companyId, Integer flag, Integer types);

	Integer OrderRepeat(Integer companyId);

	Double channelPubSharereFee(Integer companyId, Integer groupId, Integer flag);

	Double pubCommisssionPubSharePreFee(Integer companyId, Integer type, Long startDate, Long endDate);

	Integer payOrderTotalNum(Integer companyId, Integer type, Long startDate, Long endDate);

	Double payOrderTotalMoney(Integer companyId, Integer type, Long startDate, Long endDate);

	int totalGoodFreesNum(Integer companyId, Integer orderType, Integer type, Long startDate, Long endDate);

	Double totalGoodFreesMoney(Integer companyId, Integer orderType, Integer type, Long startDate, Long endDate);

	Integer sqjdOrderNum();

	Map<String,Double> sqjdCommision();

	Map<String,Double> sqjdTypeCommision(Integer companyId,Integer orderType,Integer goodFrees);

	Integer sqjdAllOrderNum();

	Map<String,Object> freeCommssion();

	Double zgsAllCommission();

	Map<String,Object> selectChannelNums(Integer type);

    JdUserOrder selectJdOrderBybalanceCount(Long userId);

	PddUserOrder selectPddOrderBybalanceCount(Long userId);

	JdUserOrder selectUserJdOrder(Long userId);

	PddUserOrder selectUserPddOrder(Long userId);
}
